﻿using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class SolMihayo1
{
    public int MyMaxValue(int[] nums)
    {
        int len=nums.Length;
        if(len == 2) return nums[0] * nums[ 1];

        int preMax = 0;
        //for (int i = 0; i < nums.Length-1; i++) { 
        
        //    int curValue=nums[i]*nums[i+1];
        //    preMax=Math.Max(preMax, curValue);

        
        //}
        //每次都是当前数字和右边的数字交换
        for (int i = 0; i < nums.Length - 1; i++)
        {

            int curValue = nums[i] * nums[i + 1];//当前价值
            int nextValue = 0;
            if (i!= nums.Length - 2)
            {
                nextValue = nums[i] * nums[i + 2];//交换的新价值
            }
          
           

           int maxValue = Math.Max(curValue, nextValue);
            preMax = Math.Max(maxValue, preMax);


        }

        return preMax;

    }
}




    public class ProgramMihayo1
{
    public static void MainMihayo1()
    {
        string line;
        

        while ((line = Console.ReadLine()) != null)
        { // 注意 while 处理多个 case
            string[] tokens = line.Split();

            int len= int.Parse(tokens[0]);//数组长度


            line = Console.ReadLine();
            tokens = line.Split();
            int[] nums= new int[len];
            for (int i = 0; i < len; i++) {
                nums[i]= int.Parse(tokens[i]);


            }

            //System.Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));

            SolMihayo1 sol= new SolMihayo1();


           int res= sol.MyMaxValue(nums);
            Console.WriteLine(res);

        }
    }
}
